package com.example.viewtest;

import java.util.List;
import java.util.Random;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import com.example.domain.group_many2many.DeveloperProject;
import com.example.domain.many2many.Developer;
import com.example.domain.many2many.Project;
import com.example.domain.many2one.Wife;
import com.example.domain.one2many.Husband;
import com.example.domain.single.Boy;
import com.example.ormlite.DBHelper_DataDir;
import com.example.ormlite.DBHelper_SetData;
import com.j256.ormlite.android.apptools.OpenHelperManager;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.Where;
@SuppressWarnings("unchecked")
public class MainActivity extends Activity {
	private Context context = this;
	/**
	 * You'll need this in your class to cache the helper in the class.
	 */
	private DBHelper_DataDir dbHelper_DataDir = null;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		
		
		
		try {
			testOnCreateUpateDB();
			testDataDir_TestData();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	private void testDataDir_TestData() {
		try {
			createAndInsertTable();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void testOnCreateUpateDB() throws Exception {
		DBHelper_DataDir dbHelper_DataDir = DBHelper_DataDir.getInstance(context);
		List<Boy> list = dbHelper_DataDir.getDao(Boy.class).queryForAll();
		for (Boy boy : list) {
			System.out.println("boy:"+boy);
		}
		
		
	}
	
	private void createAndInsertTable() throws Exception {
		Class clazz = Boy.class;
		
		DBHelper_DataDir dbHelper_DataDir = DBHelper_DataDir.getInstance(context);
		Dao dao = dbHelper_DataDir.getDao(clazz);
		for (int i = 0; i < 10; i++) {
			Object object = clazz.newInstance();
			dao.create(object);
		}
	}

	

	
}
